<?php
/**
 * json view class
 *
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.01
 */
class json_view extends view {
    protected $content = NULL;

    public function send_header() {
        header('Content-Type: application/json');
    }

    public function set_content($content) {
        if (is_array($content)) {
            if (is_array($this->content)) {
                $this->content = array_merge($this->content, $content);
            }
            else {
                $this->content = $content;
            }

            return true;
        }
        else {
            return false;
        }
    }

    public function get_content() {
        return json_encode($this->content);
    }
}
?>